home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 051-075 / disk_066 / assigned / assigned.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  2KB  |  80 lines

  1. #include "stdio.h"
  2. #include "exec/types.h"
  3. #include "libraries/dosextens.h"
  4.  
  5. #define    AS_DEVICE    0
  6. #define    AS_DIR        1
  7. #define    AS_DRIVE    2
  8. #define    AS_UNKNOWN    3
  9.  
  10. int    Assigned(searchname)
  11. char    *searchname;
  12. {
  13.     struct    DosLibrary    *DosLibrary;
  14.     struct    RootNode    *RootNode;
  15.     struct    DosInfo        *DosInfo;
  16.     struct    DeviceList    *DevInfo;
  17.     char    name[256];
  18.     char    *astr;
  19.     BSTR    bstr;
  20.     long    type;
  21.     int    i,rc;
  22.  
  23.     DosLibrary = (struct DosLibrary *)OpenLibrary("dos.library",0);
  24.     RootNode = (struct RootNode *)DosLibrary->dl_Root;
  25.     DosInfo = (struct DosInfo *)BADDR(RootNode->rn_Info);
  26.     DevInfo = (struct DeviceList *)BADDR(DosInfo->di_DevInfo);
  27.  
  28.     rc = AS_UNKNOWN;
  29.     while (DevInfo != NULL) {
  30.         type = DevInfo->dl_Type;
  31.         bstr = (BSTR)DevInfo->dl_Name;
  32.         astr = (char *)BADDR(bstr);
  33.         for (i = 0; i < astr[0]; i++)
  34.             name[i] = astr[i+1];
  35.         name[i] = '\0';
  36.         if (strcmp(name,searchname) == 0) {
  37.             rc = type;
  38.             DevInfo = NULL;
  39.         }
  40.         else
  41.             DevInfo = (struct DeviceList *)BADDR(DevInfo->dl_Next);
  42.     }
  43.     CloseLibrary(DosLibrary);
  44.     return(rc);
  45. }
  46.  
  47. main()
  48. {
  49.     char    cmd[80];
  50.  
  51.     printf("*** This program is Case Sensitive! ***\n");
  52.     printf("*** Do not append a colon: to the searchname ***\n\n");
  53.  
  54.     for (;;) {
  55.         printf("Enter search name or QUIT: ");
  56.         scanf("%s",cmd);
  57.         if (strcmp(cmd,"QUIT") == 0)
  58.             return(0);
  59.         switch ( Assigned(cmd) ) {
  60.             case AS_DEVICE:
  61.                 printf("%s is a device\n",cmd);
  62.                 break;
  63.             case AS_DIR:
  64.                 printf("%s is an assigned directory\n",cmd);
  65.                 break;
  66.             case AS_DRIVE:
  67.                 printf("%s is a mounted drive\n",cmd);
  68.                 break;
  69.             case AS_UNKNOWN:
  70.                 printf("%s is unknown\n",cmd);
  71.                 break;
  72.             default:
  73.                 printf("%s is not defined???\n",cmd);
  74.                 break;
  75.         }
  76.     }
  77. }
  78.  
  79.  
  80.